/*
 * @lc app=leetcode.cn id=1287 lang=javascript
 *
 * [1287] 有序数组中出现次数超过25%的元素
 */

// @lc code=start
/**
 * @param {number[]} arr
 * @return {number}
 */
var findSpecialInteger = function (arr) {
  let max = 1, cur = 1, res = arr[0];
  for (let i = 1; i < arr.length; i++) {
    if (arr[i] === arr[i - 1]) {
      cur++;
      if (cur > max) {
        max = cur;
        res = arr[i];
      }
    } else {
      cur = 1;
    }
  }
  return res;
};
// @lc code=end

